package br.ufrj.dcc.smarthotel.listeners;

import android.view.View;
import android.view.View.OnClickListener;
import br.ufrj.dcc.smarthotel.R;
import br.ufrj.dcc.smarthotel.TourMenuActivity;
import br.ufrj.dcc.smarthotel.activities.DashboardActivity;
import br.ufrj.dcc.smarthotel.activities.EventsMenuActivity;
import br.ufrj.dcc.smarthotel.activities.RequestedServicesActivity;
import br.ufrj.dcc.smarthotel.activities.ServicesMenuActivity;
import br.ufrj.dcc.smarthotel.controls.LoggedUserSession;

public class DashboardMenuItemClickListener implements OnClickListener {
	private DashboardActivity activity;
	
	public DashboardMenuItemClickListener(DashboardActivity activity){
		this.activity = activity;
	}
	
	public void onClick(View v) {
    	if (v.getId() == R.id.dashboardIconTour) {
    		this.activity.startActivity(TourMenuActivity.class);
    	}
    	else {
    		if (v.getId() == R.id.dashboardIconEvents) {
    			this.activity.startActivity(EventsMenuActivity.class);
    		}
    		else {
    			if (v.getId() == R.id.dashboardIconServices) {
    				if (LoggedUserSession.getInstance().getSession().getUser().getEmployeeId() == 0) {
    					this.activity.startActivity(ServicesMenuActivity.class);
    				}
    				else {
    					this.activity.startActivity(RequestedServicesActivity.class);
    				}
    			}
    			else {
    				if (v.getId() == R.id.btnLogout) {
						this.activity.finish();
					}
    			}
    		}
    	}
	}
}
